<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<!--修改档案位置模态框-->
<div class="modal fade" data-backdrop="static" data-keyboard="false" id="modal-infor">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">签收备注</h4>
            </div>
            <div class="modal-body">
                <form id="inforForm" class="form-horizontal">
                    <input type="hidden" name="id">
                    <div class="col-md-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label" >项目编号</label>
                            <div class="col-sm-10">
                                <input name="proCode" type="text" class="form-control" readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" >项目名称</label>
                            <div class="col-sm-10">
                                <input name="proName" type="text" class="form-control" readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" >类型</label>
                            <div class="col-sm-10">
                                <input name="special" type="text" class="form-control" readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" >部分</label>
                            <div class="col-sm-10">
                                <input name="part" type="text" class="form-control"  readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" >提报科室</label>
                            <div class="col-sm-10">
                                <input name="sectionName" type="text" class="form-control"  readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" >签收备注</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="fileRemark">
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="infor-edit">
                    确定
                </button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<section class="content-header">
    <h1>存档清单签收列表</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label for="query-proCode">项目编号</label>
                                    <input id="query-proCode" type="text" name="proCode" class="form-control"
                                           placeholder="请输入项目编号">
                                </div>
                                <div class="form-group">
                                    <label for="query-proName">项目名称</label>
                                    <input id="query-proName" type="text" name="proName" class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <div class="form-group">
                                    <label for="query-malType">类型</label>
                                    <select id="query-malType" class="form-control" name="specialId">
                                        <option value="" selected>请选择</option>
                                        <option th:each="type : ${malTypes}" th:value="${type.name}"
                                                th:text="${type.name}"></option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-part">部分</label>
                                    <input id="query-part" type="text" name="part" class="form-control"
                                           placeholder="请输入部分">
                                </div>
                                <div class="form-group">
                                    <label for="query-status">状态</label>
                                    <select id="query-status" class="form-control" name="fileSignStatus">
                                        <option value="">请选择</option>
                                        <option value="0" selected>未签收</option>
                                        <option value="1">已签收</option>

                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-postName">创建人</label>
                                    <input id="query-postName" type="text" name="createNameOne" class="form-control"
                                           placeholder="请输入提报人">
                                </div>
                                <div class="form-group">
                                    <label for="query-startTime">提报日期</label>
                                    <input id="query-startTime" type="text" class="form-control datepicker" name="startTime"
                                           readonly="readonly"/>
                                    <label for="query-endTime"> 至 </label>
                                    <input id="query-endTime" type="text" class="form-control datepicker" name="endTime"
                                           readonly="readonly"/>
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search"
                                        onclick="js.table.search(table)">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let table;

    $(function () {

        /** 加载列表 */
        table = js.table.init({
            url: ctx + "file/signFor/list",
            columns: [
                {title: '序号', field: 'id', width: '50px',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "项目编号", field: 'proCode'},
                {title: "项目名称", field: 'proName'},
                {title: "项目数量", field: 'proNum'},
                {title: "类型", field: 'special'},
                {title: "部分", field: 'part'},
                {title: "创建人", field: 'createNameOne'},
                {title: "单据状态", field: 'fileSignStatus',
                    formatter: function (value) {
                        if (value === 0) {
                            return '<span class="badge label-warning">未签收</span>';
                        } else if (value === 1) {
                            return '<span class="badge label-success">已签收</span>';
                        }
                    }
                },
                // {title: "提报日期", field: 'createTime'},
                {title: "提报科室", field: 'sectionName'},
                {title: "批准日期", field: 'verifyTime'},
                {title: "拒收原因", field: 'rejectReason'},
                {title: "签收时间", field: 'fileSignTime'},
                {title: "签收人", field: 'fileSigner'},
                {title: "签收备注", field: 'fileRemark'},
                {
                    title: "操作",
                    formatter: function (value, row) {
                        debugger
                        let actions = [];
                        if(row.fileSignStatus==0){
                            actions.push('<a class="btn btn-warning btn-xs" href="' + ctx + 'file/signFor/check/' + row.id + '" > 签收</a>');
                        }else{
                            actions.push('<a class="btn btn-info btn-xs" target="_blank" href="'+ ctx + 'file/signFor/info/' + row.id + '" >查看</a>');

                        }
                        actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="openEditInfor(' + js.jsonStringify(row) + ')"> 编辑</a>');
                        return actions.join('');
                    }
                }
            ]
        });

    });

    /** 修改档案位置 */
    function openEditInfor(row) {
        debugger
        $("#inforForm")[0].reset();
        $("#inforForm").fillData(row)
        js.modal.open('modal-infor')
    }

    /** 修改档案备注*/
    $("#infor-edit").click(function () {
        js.validSubmit({
            formId: "inforForm",
            url: ctx + "file/signFor/modify",
            data: new FormData($("#inforForm")[0]),
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    js.modal.success(result.msg);
                    js.modal.hide("modal-infor");
                    js.table.refresh(table);
                } else {
                    js.modal.warning(result.msg);
                }
            }
        });
    });

</script>
</body>
</html>
